//=============================================================================
//
//   Copyright (C) 2020 All rights reserved.
//
//   Filename:		time_phase.rs
//
//   Author: Wang Zhecheng - wangzhecheng@yeah.net
//
//   Date: 2020-10-27 19:39
//
//   Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
//
//   Last modified:	2020-11-06 18:27
//
//   Description:
//
//=============================================================================
use crate::component::time_sequence::StepLike;
use crate::Real;
use crate::util::Indexable;
use serde::Deserialize;

#[derive(Deserialize)]
pub struct TimePhase {
    id: Option<usize>,
    #[serde(rename = "start_time")]
    stime: Real,
    #[serde(rename = "end_time")]
    etime: Real,
    #[serde(rename = "delta_time")]
    dtime: Real,
}
step_like_impl!(TimePhase);
indexable_impl!(TimePhase);

#[test]
fn constructor() {
    let mut tstep = TimePhase {
        id: None,
        stime: 0 as Real,
        etime: 0 as Real,
        dtime: 0 as Real,
    };
    tstep.set_stime(10 as Real);
    tstep.set_etime(100 as Real);
    assert_eq!(tstep.get_stime(), 10 as Real);
    assert_eq!(tstep.get_etime(), 100 as Real);

    tstep.set_index(12);
    assert_eq!(tstep.get_index().unwrap(), 12usize);
}
